import java.util.ArrayList;
import java.util.Map;
import java.util.Scanner;
import java.util.Map.Entry;

public class ModBin {
	private ArrayList<Employee> E;
	private int max;
	private Employee e;

	public ModBin(ArrayList<Employee> $E, int $max) {
		this.E = $E;
		if (max != 0) {
			this.max = $max;
		} else {
			this.max = $E.size();
		}
	}

	public ArrayList<Employee> addEmp(int id, String name, String lastname,
			int job, String regis_date, double salary, double commission,
			int dept_Number) {
		e = new Employee(id, name, lastname, job, regis_date, salary,
				commission, dept_Number);
		E.add(e);
		return E;
	}

	public ArrayList<Employee> deleteEmp(int $id) {
		E.remove($id - 1);
		return E;
	}

	public ArrayList<Employee> modEmp(int idMod, int fieldtoMod,
			Map<Integer, String> job, Map<Integer, String> dept_number,
			Scanner sc) {
		e = E.get(idMod - 1);
		switch (fieldtoMod) {
		case 1:
			System.out.println("Actual Name: " + E.get(idMod - 1).getName());
			System.out.println("Write new Name: ");
			String newName = sc.next();
			System.out.println("The new name is: " + newName);
			E.get(idMod - 1).setName(newName);
			break;
		case 2:
			System.out.println("Actual Last Name: " + e.getLastname());
			System.out.println("Write new Last Name: ");
			String newLastName = sc.next();
			System.out.println("The new Last name is: " + newLastName);
			e.setLastname(newLastName);
			break;
		case 3:
			System.out.println("Actual profession: " + e.getJob());
			for (Entry<Integer, String> entry : job.entrySet()) {
				System.out.println("Number: " + entry.getKey() + " Job: "
						+ entry.getValue());
			}
			System.out.println("Write the number of the new Job:");
			int jobnum = sc.nextInt();
			e.setJob(jobnum);
			break;
		case 4:
			System.out
					.println("Actual Registration date: " + e.getRegis_date());
			System.out.println("Write new Registration Date:");
			String newReg = sc.next();
			e.formatDate(newReg);
			break;
		case 5:
			System.out.println("Actual Salary: " + e.getSalary());
			System.out.println("Change current Salary to: ");
			double newSalary = sc.nextDouble();
			e.setSalary(newSalary);
			break;
		case 6:
			System.out.println("Actual Commission: " + e.getCommission());
			System.out.println("Change current Commission to: ");
			double newCommission = sc.nextDouble();
			e.setCommission(newCommission);
			break;
		case 7:
			for (Entry<Integer, String> entry : dept_number.entrySet()) {
				System.out.println("Number: " + entry.getKey()
						+ " Department: " + entry.getValue());
			}
			System.out.println("Actual department: " + e.getDept_Number());
			System.out.println("Write the number of the new department:");
			int newdept_number = sc.nextInt();
			e.setDept_Number(newdept_number);
			break;
		}
		return this.E;
	}
}
